                                                                                                          <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('系统管理员操作界面')"/>
    <!--<th:block th:include="include :: bootstrap-select-css"/>-->
    <!--<th:block th:include="include :: jasny-bootstrap-css"/>-->
    <!--<th:block th:include="include :: datetimepicker-css"/>-->
    <link th:href="@{/ruoyi/css/font-awesome.css}" rel="stylesheet"/>
    <link th:href="@{/ruoyi/css/jquery-confirm.min.css}" rel="stylesheet"/>
</head>
<style type="text/css">

    @media screen and (max-width: 768px) {
        #isglyspan{
            font-family: 微软雅黑;font-size: 24px;
        }
        #isyly_lab{
            margin-top: 0px;margin-left: 50px;
        }
        #isgly_add{
            width: 40px
        }
        .glydiv{
            margin-left: 0px;
        }
    }

    /**电脑屏幕下显示***/
    @media screen and (min-width: 768px) {
        body {
            /*text-align:center;*/
            margin: 0px auto;
        }
        #form-sb-add input{

        }

        #form-sb-add label{
            margin-left: -60px;
        }

        #isglyspan{
            font-family: 微软雅黑;font-size: 24px;margin-left: -70px
        }
        #isgly_add{
            width: 40px
        }
        .glydiv{
            margin-left: 300px;
        }
    }
</style>
<body class="gray-bg">
<!--//部门名称发生变化模态框开始-->
<div class="modal fade" id="bmupdate" tabindex="-1" role="dialog" aria-hidden="true"
     data-keyboard="false">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span>
                </button>
                <h1 class="modal-title"><strong>部门名称修改</strong></h1>
            </div>
            <div class="modal-body">
                <form id="form-bm-update" class="form-horizontal">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">公司编码</label>
                            <div class="col-sm-8">
                                <input name="gsid" id="gsid_update" class="form-control" type="hidden" required="required">
                                <select class="form-control m-b qbinput" id="bmid_update">
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">部门名称</label>
                            <div class="col-sm-8">
                                <div>
                                    <select name="bm_update" class="form-control m-b" id="bmmc_update"></select>
                                    <span class="help-block"></span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">修改部门</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <input name="bm" id="bm_up" class="form-control" type="text" required="required">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <div class="modal-footer">
                                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                <button type="button" class="btn btn-white" id="bm_update_btn" onclick="update_bm()">更新
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!--//部门名称发生变化模态框开始-->
<!--添加部门人员开始-->
<div class="modal fade" id="tjbmryModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog modal-xl" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="tjModalLabel">添加解决方案</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2">部门名称</label>
                        <div class="col-sm-10">
                            <input type="text" name="bmmc" class="form-control" id="tj_bmmc"
                                   placeholder="请输入添加部门名称">
                            <span class="help-block"></span>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="tj_jjfa_btn">添加</button>
            </div>
        </div>
    </div>
</div>
<!--添加部门人员结束-->
<!--编辑模态框开始-->
<div class="modal fade" id="sbUpdateModal" tabindex="-1" role="dialog" aria-hidden="true"
     data-keyboard="false">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span>
                </button>
                <h1 class="modal-title"><strong>编辑公司名称</strong></h1>
            </div>
            <div class="modal-body">
                <form id="form-sb-update" class="form-horizontal">
                    <div class="row" style="display: none">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">公司编码</label>
                            <div class="col-sm-8">
                                <input name="gsid" id="gsid_up" class="form-control" type="text" required="required">
                                <input id="uId_up" class="form-control" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">登录账户</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <input name="loginName" id="lname_up" class="form-control" type="text" required="required">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">用户姓名</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <input name="shiyr" id="uname_up" class="form-control" type="text" required="required">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row" style="display: none">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">部门</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <input name="bm" id="bmmc_up" class="form-control" type="text" required="required">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">是否管理</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <select class="form-control" name="isgly" id="isgly_up" style="width: 335%">
                                        <option value="是">是</option>
                                        <option value="否">否</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <div class="modal-footer">
                                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                <button type="button" class="btn btn-white" id="sb_update_btn" onclick="updateygxxb()">更新
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!--编辑模态框结束-->
<!--添加模态框开始-->
<div class="modal fade" id="sbAddModal" tabindex="-1" role="dialog" aria-hidden="true"
     data-keyboard="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span>
                </button>
                <h1 class="modal-title"><strong>添加部门人员</strong></h1>
            </div>
            <div class="modal-body">
                <form id="form-sb-add" class="form-horizontal">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">公司编码</label>
                            <div class="col-sm-8">
                                <input name="gsid" id="gsid_add" class="form-control" type="hidden" placeholder="请输入公司ID编码"
                                       required="required">
                                <select class="form-control m-b qbinput" id="bmid_id">
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">部门名称</label>
                            <div class="col-sm-6">
                                <div>
                                    <select name="bm" class="form-control m-b" id="bmmc_add">
                                    </select>
                                    <span class="help-block"></span>
                                </div>
                            </div>
                            <div class="col-sm-2" id="add_jjfa_div">
                                <button type="button" class="btn btn-white" id="add_bmmc">添加部门</button>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">人员姓名</label>
                            <div class="col-sm-8">
                                <input name="shiyr" id="shiyr_add" class="form-control" type="text" placeholder="请输入设备使用人"
                                       required="required">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">登录账户</label>
                            <div class="col-sm-8">
                                <input name="loginName" id="loginName_add" class="form-control" type="text" placeholder="请输入设备使用人"
                                       required="required">
                            </div>
                        </div>
                    </div>
                    <div class="row" style="display: none">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">登录密码</label>
                            <div class="col-sm-8">
                                <input name="loginPassword" id="loginPassword_add" class="form-control" type="text" placeholder="请输入设备使用人" value="admin"
                                       required="required">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                    <div class="col-sm-4 glydiv">
                    <input name="isgly" id="isgly_add"  class="form-control" type="checkbox">
                    </div>
                    <div class="col-sm-8" ></div>
                    <label for="isgly_add" id="isyly_lab"><span id="isglyspan">是否管理员</span></label>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <div class="modal-footer">
                                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                <button type="button" class="btn btn-white" id="sb_save_btn" onclick="savesb()">保存
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!--添加模态框结束-->
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="operlog-form">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>检索：</label><input type="text" name="sbbh" id="sbbh" placeholder="请输入部门名称或员工姓名或姓名助记码进行查询"
                                                     onkeydown="if(event.keyCode==13){event.keyCode=0;event.returnValue=false;$.alert('请点击后面的搜索框','温馨提示');}"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" id="search_btn"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="addgsmc()">
                <i class="fa fa-pencil"></i> 添加部门人员
            </a>
            <a class="btn btn-success" onclick="updatebm()">
                <i class="fa fa-pencil"></i> 修改部门名称
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div><input type="hidden" id="_pageNumber"></div>
<div><input type="hidden" id="_pageSize"></div>
<p id="pusername" style="display: none">[[${session.username}]]</p>
<p id="pgsid" style="display: none">[[${session.gsid}]]</p>
<th:block th:include="include :: footer"/>
<script th:src="@{/ruoyi/js/jquery-confirm.min.js}"></script>
<script th:inline="javascript">
    // var sessionname = [[${session.username}]]
    // var gsid = [[${session.gsid}]]
    $(document).ready(function () {
        // $("#dengmz").val(sessionname)
        // if (gsid == null) {
        //     alert("当前状态未登陆系统或浏览器中当前会话结束了，您需要重新登陆")
        //     window.location.href = "/login";
        // }
        // $("#gsids").val(gsid)
        initUserTable();

        function initUserTable() {
            $("#bootstrap-table").bootstrapTable({
                toolbar: '#toolbar',
                showToggle: true,//是否切换显示
                showColumns: true,//是否显示列，
                showColumnsToggleAll: true,
                // detailView: true,//和下面的属性成对设置，是否显示加号显示详细信息
                // detailFormatter: "detailFormatter",
                showExport: true,//是否导出
                // showPaginationSwitch: true,//切换是否分页显示
                showFooter: true,//是否显示页脚，主要用途是显示汇总的信息
                striped: false,//是否显示行间隔色
                paginationPreText: '上一页',
                paginationNextText: '下一页',
                queryParamsType: '',
                method: 'GET',
                uniqueId: "id",
                exportDataType: "basic", //basic', 'all', 'selected'.
                // exportTypes:['Excel'],  //导出文件类型
                pageNumber: 'form' ? 1 : parseInt($('#_pageNumber').val()),
                pagination: true,//是否分页
                sidePagination: 'server',//server:服务器端分页|client：前端分页
                pageSize: 'form' ? 10 : parseInt($('#_pageSize').val()),//单页记录数
                pageList: [10, 20, 30, 'ALL'],//可选择单页记录数
                showRefresh: true,//刷新按钮
                queryParams: queryParams,
                // onDblClickRow: function (row,index) {
                //     console.log(index[0])
                // },
                url: "/sbgl/ygxxb/getygxxblist/",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'no',
                        title: '序号',
                        align: "center",
                        width: 60,
                        formatter: function (value, row, index) {
                            return index + 1;
                        }
                    },
                    {
                        field: 'gsid',
                        title: '公司编码'
                    },
                    {
                        field: 'bm',
                        title: '部门名称'
                    },
                    {
                        field: 'shiyr',
                        title: '使用人'
                    },
                    {
                        field: 'zjm',
                        title: '助记码'
                    },
                    {
                        field: 'loginName',
                        title: '登录账户'
                    },
                    {
                        field: 'isgly',
                        title: '是否管理员'
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function (value, row, index) {
                            var id = index;
                            var result = "";
                                result += "<a href='javascript:;' class='btn btn-xs blue'  onclick=\"EditViewById('" + row + "','" + id + "')\" title='人员停用'><span class='glyphicon glyphicon-stop'></span></a>";
                                result += "<a href='javascript:;' class='btn btn-xs blue'  onclick=\"EditById('" + row + "','" + id + "')\" title='编辑'><span class='glyphicon glyphicon-pencil'></span></a>";
                                result += "<a href='javascript:;' class='btn btn-xs blue'  onclick=\"UpdateMxById('" + row + "','" + id + "')\" title='重置登录密码'><span class='glyphicon glyphicon-search'></span></a>";
                                result += "<a href='javascript:;' class='btn btn-xs blue'  onclick=\"xiugaiksdlbh('" + row + "','" + id + "')\" title='修改快速登录密码'><span class='glyphicon glyphicon-edit'></span></a>";
                                return result;
                        }
                    }
                ]
            })
        }})
    function queryParams(params) {
        var param = {
            limit: params.limit, // 页面大小
            offset: params.offset, // 页码
            nextPage: params.pageNumber,
            pageNumber: params.pageNumber,
            pageSize: params.pageSize,
            cxtj: $("#sbbh").val(),
            gsid: $("#pgsid").text(),
            // bfbs: $("#is_bf").val(),
        };
        return param;
    }

    $('#search_btn').click(function () {
        refresh()
    });

    function refresh() {
        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;
        //获取当前是第几页
        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;
        $("#_pageNumber").val(pageNumber);
        $("#_pageSize").val(pageSize);
        $('#bootstrap-table').bootstrapTable('refresh', {
            pageNumber: pageNumber,
            pageSize: pageSize,
        });
    }
    function addgsmc() {
        var gsid=$("#pgsid").text()
        $("#gsid_add").val(gsid)
        $("#shiyr_add").val("")
        $("#loginName_add").val("")
        $("#loginPassword_add").val("")
        $("#sbAddModal").modal({
            backdrop: "static"
        });
        $("#bmmc_add").empty()
        $.ajax({
            url: '/sbgl/gsxxb/getgsxxb',
            type: 'get',
            async: false,
            success: function (result) {
                $("#bmid_id").empty();
                var options = "";   //字符串拼接
                $("#bmid_id").append('<option value="0">请选择公司名称</option>');
                for (var i in result) {  //遍历json数组
                    options += "<option value='" + result[i].gsid + "'>" + result[i].gs + "</option>"
                }
                $("#bmid_id").append(options);
            }
        })
        var gsid_add=$("#gsid_add").val()
        if (gsid_add==""){
            gsid_add=0
        }else {
            $('#bmid_id').attr("disabled", "disabled").unbind("click")
            $.ajax({
                url: "/sbgl/ygxxb/getbm/" + gsid_add,
                type: 'GET',
                async: false,
                success: function (data) {
                    $('#bmmc_add').empty();
                    var options = "";   //字符串拼接
                    $("#bmmc_add").append('<option value="">请选择部门</option>');
                    for (var i in data) {  //遍历json数组
                        options += "<option value='" + data[i].bm + "'>" + data[i].bm + "</option>"
                        //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                    }
                    $('#bmmc_add').append(options);
                }
            })
        }
        $("#bmid_id").val(gsid_add);
    }

    $("#bmid_id").change(function () {
        var gsid = $("#bmid_id option:selected").val()
        $.ajax({
            url: "/sbgl/ygxxb/getbm/" + gsid,
            type: 'GET',
            async: false,
            success: function (data) {
                $('#bmmc_add').empty();
                var options = "";   //字符串拼接
                $("#bmmc_add").append('<option value="">请选择部门</option>');
                for (var i in data) {  //遍历json数组
                    options += "<option value='" + data[i].bm + "'>" + data[i].bm + "</option>"
                    //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                }
                $('#bmmc_add').append(options);
            }
        })
        $("#gsid_add").val(gsid)
    })

    function updatebm() {
        var gsid=$("#pgsid").text()
        $("#gsid_update").val(gsid)
        $("#bm_up").val("")
        $("#bmupdate").modal({
            backdrop: "static"
        });
        $.ajax({
            url: '/sbgl/gsxxb/getgsxxb',
            type: 'get',
            async: false,
            success: function (result) {
                $("#bmid_update").empty();
                var options = "";   //字符串拼接
                $("#bmid_update").append('<option value="0">请选择公司名称</option>');
                for (var i in result) {  //遍历json数组
                    options += "<option value='" + result[i].gsid + "'>" + result[i].gs + "</option>"
                }
                $("#bmid_update").append(options);
            }
        })
        var gsid_update=$("#gsid_update").val()
        if (gsid_update==""){
            gsid_update=0
        }else {
            $("#bmid_update").val(gsid_update);
            $('#bmid_update').attr("disabled", "disabled").unbind("click")
            var gsid = $("#bmid_update option:selected").val()
            $.ajax({
                url: "/sbgl/ygxxb/getbm/" + gsid,
                type: 'GET',
                async: false,
                success: function (data) {
                    $('#bmmc_update').empty();
                    var options = "";   //字符串拼接
                    $("#bmmc_update").append('<option value="">请选择部门</option>');
                    for (var i in data) {  //遍历json数组
                        options += "<option value='" + data[i].bm + "'>" + data[i].bm + "</option>"
                        //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                    }
                    $('#bmmc_update').append(options);
                }
            })
            $("#gsid_update").val(gsid)
        }
    }
    $("#bmid_update").change(function () {
        var gsid = $("#bmid_update option:selected").val()
        $.ajax({
            url: "/sbgl/ygxxb/getbm/" + gsid,
            type: 'GET',
            async: false,
            success: function (data) {
                $('#bmmc_update').empty();
                var options = "";   //字符串拼接
                $("#bmmc_update").append('<option value="">请选择部门</option>');
                for (var i in data) {  //遍历json数组
                    options += "<option value='" + data[i].bm + "'>" + data[i].bm + "</option>"
                    //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                }
                $('#bmmc_update').append(options);
            }
        })
        $("#gsid_update").val(gsid)
    })
    function savesb() {
        var gsid=$("#gsid_add").val()
        var bm=$("#bmmc_add").val()
        var xinbm=$("#tj_bmmc").val()
        var name=$("#shiyr_add").val()
        var lgname=$("#loginName_add").val()
        if (lgname=="administrator"){
            $.alert("不能使用该登录名注册","温馨提示")
            return false;
        }
        if (xinbm!=""){
            $("#shiyr_add").val(xinbm+"-公用")
            var isygxxb = cfpd("/sbgl/ygxxb/getygxxb/", gsid)
            var shiyrs=[]
            for (var i in isygxxb){
                shiyrs.push(isygxxb[i].shiyr)
            }
            if(shiyrs.indexOf($("#shiyr_add").val())>=0){
                $.alert("你直接点击保存将添加公用账号，但是该公用账号已存在不允许保存","温馨提示")
                return false
            }
            $("#shiyr_add").attr("readonly", "readonly")
            $.confirm({
                title: '温馨提示!',
                content: '添加人员信息，是否继续',
                buttons: {
                    确定: {
                        text: '确定',
                        btnClass: 'btn-blue',
                        action: function () {
                            return $.ajax({
                                url: '/sbgl/ygxxb/insertyg',
                                async: false,
                                method: 'POST',
                                data: $("#sbAddModal form").serialize(),
                            }).done(function (data) {
                                $.alert("人员添加成功", "温馨提示")
                                $("#sbAddModal").modal('hide');
                                refresh()
                            }).fail(function () {
                            })
                        }
                    },
                    取消: {
                        text: '取消',
                        btnClass: 'btn-red',
                        action: function () {
                        },
                    },
                }
            });
        }else {
            if (bm==""||name.length<=1||lgname.length<=2) {
                $.alert("请选择部门且人员姓名的长度不能小于2登录账号的长度不能小于3", "温馨提示")
                return false;
            }
            var isygxxb = cfpd("/sbgl/ygxxb/getygxxb/", gsid)
            var isshiyr = panduan("/sbgl/ygxxb/getbmbyshiyrandbm/",name,bm,gsid)
            var bms=[]
            var names=[]
            var lgnames=[]
            for (var i in isygxxb){
                if (bms.indexOf(bm) == -1) {
                    bms.push(isygxxb[i].bm)
                }
                names.push(isygxxb[i].shiyr)
                lgnames.push(isygxxb[i].loginName)
            }
            if (lgnames.indexOf(lgname)>=0) {
                $.alert("登录账号重复了","温馨提示")
                return false
            }
            if (isshiyr!="全公司上下查无此人"){
                $.confirm({
                    title: '温馨提示!',
                    content: '该部门已经有该员工信息了，是否继续',
                    buttons: {
                        确定: {
                            text: '确定',
                            btnClass: 'btn-blue',
                            action: function () {
                                return $.ajax({
                                    url: '/sbgl/ygxxb/insertyg',
                                    async: false,
                                    method: 'POST',
                                    data: $("#sbAddModal form").serialize(),
                                }).done(function (data) {
                                    $.alert("人员添加成功","温馨提示")
                                    $("#sbAddModal").modal('hide');
                                    refresh()
                                }).fail(function () {
                                })
                            }
                        },
                        取消: {
                            text: '取消',
                            btnClass: 'btn-red',
                            action: function () {
                            },
                        },
                    }
                });
            } else {
                $.confirm({
                    title: '温馨提示!',
                    content: '添加人员信息，是否继续',
                    buttons: {
                        确定: {
                            text: '确定',
                            btnClass: 'btn-blue',
                            action: function () {
                                return $.ajax({
                                    url: '/sbgl/ygxxb/insertyg',
                                    async: false,
                                    method: 'POST',
                                    data: $("#sbAddModal form").serialize(),
                                }).done(function (data) {
                                    $.alert("人员添加成功", "温馨提示")
                                    $("#sbAddModal").modal('hide');
                                    refresh()
                                }).fail(function () {
                                })
                            }
                        },
                        取消: {
                            text: '取消',
                            btnClass: 'btn-red',
                            action: function () {
                            },
                        },
                    }
                });
            }
        }

    }

    function confirm(title,content,ele) {
        $.confirm({
            title: title,
            content: content,
            buttons: {
                确定: {
                    text: '确定',
                    btnClass: 'btn-blue',
                    action: function(){
                        $(ele).modal('hide');
                    }
                }
            }
        });
    }
    function EditViewById(row, index)  {
        var data = JSON.stringify($("#bootstrap-table").bootstrapTable('getData')); //获取全部数据
        var data_json = JSON.parse(data);
        var id=data_json[index].id;
        var shiyr=data_json[index].shiyr;
        $.confirm({
            title: '人员删除',
            content: '您现在的操作是人员删除，您确定删除'+shiyr+'吗？',
            buttons: {
                确认: function () {
                    $.ajax({
                        url: "/sbgl/ygxxb/remove/" + id,
                        type: 'POST',
                        success: function (result) {
                            if (result != null) {
                                confirm('温馨提示','人员删除成功！！！')
                                refresh()
                            }
                        }
                    });
                },
                取消: function () {
                }
            }
        });
    }
    function updateygxxb() {
        var gsid= $('#gsid_up').val()
        var lgname= $('#lname_up').val()
        var name= $('#uname_up').val()
        var bm= $('#bmmc_up').val()
        var uid = $('#uId_up').val()
        var isygxxb = cfpd("/sbgl/ygxxb/getygxxb/", gsid)
        var bms=[]
        var names=[]
        var lgnames=[]
        for (var i in isygxxb){
            if (bms.indexOf(bm) == -1) {
                bms.push(isygxxb[i].bm)
            }
            names.push(isygxxb[i].shiyr)
            lgnames.push(isygxxb[i].loginName)
        }
        if (lgnames.indexOf(lgname)>=0) {
            $.alert("登录账号重复了","温馨提示")
            return false
        }
        if (bms.indexOf(bm)>=0&&names.indexOf(name)>=0){
            $.confirm({
                title: '温馨提示!',
                content: '该部门已经有该员工信息了，是否继续？？？',
                buttons: {
                    确定: {
                        text: '确定',
                        btnClass: 'btn-blue',
                        action: function () {
                            return $.ajax({
                                url: '/sbgl/ygxxb/updateygxxbbyid/' + uid,
                                async: false,
                                method: 'PUT',
                                data: $("#sbUpdateModal form").serialize(),
                            }).done(function (data) {
                                $.alert("人员更新成功","温馨提示")
                                $("#sbUpdateModal").modal('hide');
                                refresh()
                            }).fail(function () {
                            })
                        }
                    },
                    取消: {
                        text: '取消',
                        btnClass: 'btn-red',
                        action: function () {
                        },
                    },
                }
            });
        }
    }

    function EditById(row, index)  {
        var data = JSON.stringify($("#bootstrap-table").bootstrapTable('getData')); //获取全部数据
        var data_json = JSON.parse(data);
        $("#emp_update_btn").val(data_json[index].gsid);
        $('#sbUpdateModal').modal('show');
        $('#gsid_up').val(data_json[index].gsid)
        $('#lname_up').val(data_json[index].loginName)
        $('#uname_up').val(data_json[index].shiyr)
        $('#isgly_up').val(data_json[index].isgly)
        $('#uId_up').val(data_json[index].id)
        $('#bmmc_up').val(data_json[index].bm)
    }

    function update_bm(){
        var gsid = $('#gsid_update').val()
        var bm=$("#bmmc_update").val()
        var xbm=$("#bm_up").val()
        if (bm==""||xbm==""){
            $.alert("请选择部门名称和填写要修改的部门名称","温馨提示")
            return false
        }
        var isygxxb = cfpd("/sbgl/ygxxb/getygxxb/", gsid)
        var bms = []
        for (var i in isygxxb) {
            if (bms.indexOf(bm) == -1) {
                bms.push(isygxxb[i].bm)
            }
        }
        if (bms.indexOf(xbm) >= 0) {
            $.alert("部门信息重复", "温馨提示")
            return false
        }
        $.confirm({
            title: '温馨提示',
            content: '确定部门由【'+bm+'】修改成【'+xbm+'】吗？？？',
            buttons: {
                确定: {
                    text: '确定',
                    btnClass: 'btn-blue',
                    action: function () {
                        return $.ajax({
                            url: '/sbgl/ygxxb/updateygxxbbygsid/' + gsid + '/' + bm,
                            method: 'PUT',
                            data: $("#bmupdate form").serialize()
                        }).done(function (response) {
                            $("#bmupdate").modal('hide');
                            $.alert("更新成功！！！","温馨提示")
                            refresh()
                        }).fail(function () {
                        });
                    }
                },
                取消: {
                    text: '取消',
                    btnClass: 'btn-red',
                    action: function () {
                    },
                },
            },
        });
    }

    $('#add_bmmc').click(function () {
        $('#sbAddModal').modal('toggle');
        $("#tjbmryModal").modal({
            backdrop: "static"
        });
        $('#tj_bmmc').val("")
    });

    $("#tj_jjfa_btn").click(function () {
        if ($("#tj_bmmc").val()==""||$("#tj_bmmc").val().indexOf(" ")!=-1){
            $.alert("部门名称不能为空同时部门名称中不能包含空格","温馨提示")
            return false
        }
        var option = $("<option />");
        option.html($("#tj_bmmc").val());
        option.val($("#tj_bmmc").val());
        $("#bmmc_add").append(option);
        $('#tjbmryModal').modal('toggle');
        $("#sbAddModal").modal({
            backdrop: "static"
        });
        $("#bmmc_add option:last").attr("selected","selected")

        // $('#shiyr_add').attr("disabled", "disabled").unbind("click")
        // $('#loginName_add').attr("disabled", "disabled").unbind("click")

    })

    function UpdateMxById(row, index)  {
        var data = JSON.stringify($("#bootstrap-table").bootstrapTable('getData')); //获取全部数据
        var data_json = JSON.parse(data);
        var uId=data_json[index].id;
        var loginName=data_json[index].loginName;
        $.confirm({
            title: '温馨提示',
            content: loginName+'的密码重置为admin吗？？？',
            buttons: {
                确定: {
                    text: '确定',
                    btnClass: 'btn-blue',
                    action: function () {
                        return $.ajax({
                            url: '/sbgl/ygxxb/updatepassword/'+uId,
                            method: 'PUT',
                            data: {
                                loginPassword: "21232f297a57a5a743894a0e4a801fc3",
                            },
                            dataType: "JSON",
                        }).done(function (response) {
                            $.alert("重置成功！！！","温馨提示")
                            refresh()
                        }).fail(function () {
                        });
                    }
                },
                取消: {
                    text: '取消',
                    btnClass: 'btn-red',
                    action: function () {
                    },
                },
            },
        });
    }

    function xiugaiksdlbh(row, index)  {
        var data = JSON.stringify($("#bootstrap-table").bootstrapTable('getData')); //获取全部数据
        var data_json = JSON.parse(data);
        var uId=data_json[index].id;
        let yc = $.confirm({
            title: '温馨提示',
            content: ''+
                '<form action="" class="formName">' +
                '<div class="row"><div class="form-group">' +
                '<label style="float: left;margin-left: 20px;margin-top: 5px">快登编号：</label>' +
                '<input type="text" placeholder="请输入用户名" class="ksdlbh form-control" style="width: 60%;float: right;margin-top: 0px;margin-right: 20px"/></div>' +
                '</form>',
            buttons: {
                确定: {
                    text: '确定',
                    btnClass: 'btn-blue',
                    action: function () {
                        var ksdlbh = this.$content.find('.ksdlbh').val();
                        if (!ksdlbh){
                            $.confirm({
                                title: '温馨提示',
                                content: '你输入的快速登录编号为空',
                                buttons: {
                                    确定: {
                                        text: '确定',
                                        btnClass: 'btn-blue',
                                        action: function () {
                                            yc.open()
                                        }
                                    },
                                },
                            });
                        }else {
                            $.ajax({
                                url: '/sbgl/ygxxb/getksdlbhcount/'+ksdlbh,
                                type: 'GET',
                                success: function (result) {
                                    if(result.indexOf("已存在")!=-1){
                                        $.confirm({
                                            title: '温馨提示',
                                            content: result,
                                            buttons: {
                                                确定: {
                                                    text: '确定',
                                                    btnClass: 'btn-blue',
                                                    action: function () {
                                                        yc.open()
                                                    }
                                                },
                                            },
                                        });
                                    } else {
                                        return $.ajax({
                                            url: '/sbgl/ygxxb/updateksdlbh/'+uId,
                                            method: 'PUT',
                                            data: {
                                                ksdlbh: ksdlbh,
                                            },
                                            dataType: "JSON",
                                        }).done(function (response) {
                                            $.alert("修改成功！！！","温馨提示")
                                            refresh()
                                        }).fail(function () {
                                        });
                                    }
                                }
                            });
                        }
                    }
                },
            },
        });
    }

</script>
</body>
</html>